package com.example.apione.controller.admin;

import com.alibaba.fastjson2.JSONObject;
import com.example.apione.utils.ResponseResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

/**
 * @author 尘落
 * @date 2023/2/26
 */
@RestController
public class IPutils {
    @GetMapping("/api/ip")
    public ResponseResult<JSONObject> getipmac(@RequestParam("ip") String ip){
        WebClient webClient=WebClient.builder().build();
        Mono<String> mono= webClient
                .get()
                .uri("https://ip.useragentinfo.com/json?ip="+ip)
                .retrieve()
                .bodyToMono(String.class);
        JSONObject data=JSONObject.parseObject(mono.block());
        return ResponseResult.ok(data);

    }
}
